package com.base.controller;

import com.base.entity.bo.ExpertBo;
import com.base.entity.bo.ExpertGroupBO;
import com.base.entity.bo.ExpertGroupRelateBo;
import com.base.entity.bo.SciencePersonBo;
import com.base.entity.vo.ExpertGroupVo;
import com.base.entity.vo.SciencePersonVo;
import com.base.service.ExpertGroupService;
import com.base.service.SciencePersonService;
import com.base.utils.CutPageBean;
import com.base.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "专家分组")
@RestController
@RequestMapping("/zjfz")
public class ExpertGroupController {
    @Autowired
    ExpertGroupService expertGroupService;
    @PostMapping("/selectExpertGroupList")
    @ApiOperation(value = "查询专家人才分组列表")
    public Result selectExpertGroupList(@RequestBody ExpertGroupVo expertGroupVo){
        CutPageBean<ExpertGroupBO> cutPageBean =expertGroupService.selectExpertGroupList(expertGroupVo);
        return Result.succ(cutPageBean);
    }

    @PostMapping("/insertExpertGroup")
    @ApiOperation(value = "新增专家分组")
    public Result insertExpertGroup(@RequestBody ExpertGroupBO expertGroupBO){
        int row=expertGroupService.insertExpertGroup(expertGroupBO);
        if (row > 0) {
            return Result.succ("新增成功");
        } else {
            return Result.fail("新增失败");
        }
    }

    @PostMapping("/updateExpertGroup")
    @ApiOperation(value = "编辑专家分组")
    public Result updateExpertGroup(@RequestBody ExpertGroupBO expertGroupBO){
        int row=expertGroupService.updateExpertGroup(expertGroupBO);
        if (row > 0) {
            return Result.succ("更新成功");
        } else {
            return Result.fail("更新失败");
        }
    }

    @PostMapping("/deletExpertGroup")
    @ApiOperation(value = "删除专家分组")
    public Result deletExpertGroup(@RequestBody ExpertGroupBO expertGroupBO){
        int row=expertGroupService.deletExpertGroup(expertGroupBO);
        if (row > 0) {
            return Result.succ("删除成功");
        } else {
            return Result.fail("删除失败");
        }
    }

    @PostMapping("/insertExpertGroupPerson")
    @ApiOperation(value = "新增专家分组成员")
    public Result insertExpertGroupPerson(@RequestBody ExpertGroupRelateBo expertGroupRelateBo){
        int row=expertGroupService.insertExpertGroupPerson(expertGroupRelateBo);
        if (row == 1) {
            return Result.succ("新增成功");
        } else if(row ==0){
            return Result.fail("新增失败");
        }else {
            return Result.succ("修改成功");
        }
    }

    @PostMapping("/deletExpertGroupPerson")
    @ApiOperation(value = "删除专家分组成员")
    public Result deletExpertGroupPerson(@RequestBody ExpertGroupRelateBo expertGroupRelateBo){
        int row=expertGroupService.deletExpertGroupPerson(expertGroupRelateBo);
        if (row > 0) {
            return Result.succ("删除成功");
        } else {
            return Result.fail("删除失败");
        }
    }

}
